package com.mju.service;

import com.mju.dao.DistrictDao;
import com.mju.pojo.District;
import com.mju.service.IDistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DistrictServiceImpl implements IDistrictService {
    @Autowired
    private DistrictDao districtDao;

    @Override
    public List<District> getByParent(String parent) {
        List<District> list = districtDao.selectByParent(parent);

        for (District district:
             list) {
            district.setId(null);
            district.setParent(null);
        }

        return list;
    }

    @Override
    public String getNameByCode(String code) {
        return districtDao.selectByCode(code);
    }
}
